package com.qf.com.qf.grass.task;

import com.qf.com.qf.grass.service.GrassService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zdl
 * @date 2025/3/31
 */
@Component
public class GrassXxlTask {
    @Resource
    private GrassService grassService;

    // xxljob 中提供修饰任务的注解，参数表示任务的名称
    @XxlJob(value = "printInfoTask")
    public void printInfo(){
        System.out.println("test xxl job");
    }

    @XxlJob(value = "batchUpdateLikeNumTask")
    public void updateLikeNumTask(){
        grassService.batchUpdateLikeNum();
    }

    @XxlJob(value = "updateViewEnabledTask")
    public void updateViewEnable(){
        String param = XxlJobHelper.getJobParam();
        grassService.updateGrassStatus(Integer.parseInt(param), 1);  // 由 0 改为 1
        System.out.println("update  grass view status");
    }
}
